import random

import config


class RechargeApi:
    # 获取充值验证码
    def get_recharge_Code(self,session) :
        resp = session.get(url=f'{config.BASE_URL}/common/public/verifycode/0.{random.randint(1000,9999)}')
        return resp


    # 充值
    def recharge(self,session, paymentType, amount,formStr,valicode):
        resp = session.post(url=f'{config.BASE_URL}/trust/trust/recharge',
                     data={'paymentType':paymentType,
                           'amount':amount,
                           'formStr':formStr,
                           'valicode':valicode
        })
        return resp

    # 投资
    def invest(self,session, id, depositCertificate, amount):
        resp = session.post(url=f'{config.BASE_URL}/trust/trust/tender',
                     data={'id':id,
                           'depositCertificate':depositCertificate,
                           'amount':amount
        })
        return resp
